package net.jmchilton.spring.collect.jcf;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * This class contains static methods for doing simple things with 
 * objects from the Java Collections Framework via static methods
 * so that they be exposed in Spring XML using the same mechanism 
 * used for other static methods, such as the methods on {@link 
 * java.util.Collections}.
 * 
 * @author John Chilton
 */
public class JcfUtils {

  /**
   * Returns the key {@link Set} corresponding to the
   * supplied {@link Map} {@code map}.
   *
   * @param <T> Type of {@code map} keys.
   * @param map Input {@link Map}
   * @return The key {@link Set} corresponding to the supplied {@link Map} {@code map}. 
   */
  public static <T> Set<T> mapToKeySet(final Map<T, ?> map) {
    return map.keySet();
  }

  /**
   * Returns the values {@link Collection} corresponding to the
   * supplied {@link Map} {@code map}.
   * 
   * @param <T> Type of {@code map} values.
   * @param map Input {@link Map}
   * @return The values {@link Collection} corresponding to the supplied {@link Map} {@code map}. 
   */
  public static <T> Collection<T> mapToValues(final Map<?, T> map) {
    return map.values();
  }
  
  
}
